package com.maduar.mybatis.demo;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.encoding.XMLType;

import com.alibaba.fastjson.JSON;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.junit.Test;

/**
 * Description:
 *
 * @author maduar maduar@163.com
 * @date 2021-04-21 23:13
 */
public class test {

    private final String url = "http://www.cbml.com.cn:8997/LisWebService.asmx?wsdl";
    private final String method = "HelloWorld";
    private final String temp = "就是一个测试的访问";
    private final String param = "TestValue";


    @Test
    public void Test() {
        try {
            String  uurl = "http://tempuri.org/";

            Service service = new Service();
            Call call =(Call) service.createCall();
            call.setTargetEndpointAddress(new URL(url));
            call.setOperationName(new QName(uurl, method));      // WSDL里面描述的接口名称
            call.addParameter(param, XMLType.XSD_STRING, ParameterMode.IN);    // 接口的参数类型
            call.setEncodingStyle("UTF-8");
            call.setReturnType(XMLType.XSD_STRING);   // 设置返回值类型
            String result =(String) call.invoke(new Object[]{temp});    //传入参数并返回返回值
            System.out.println("result: " + result);
        } catch (ServiceException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}
